const mongoose = require("mongoose");
const config = require("./index");
const morgan = require("morgan");

module.exports = {
    connect: () => {
        mongoose
            .connect(config.DB_URL)
            .then(() => {
                console.log("Connected to MongoDB");
            })
            .catch((err) => {
                console.log("Error connecting to MongoDB", err);
                process.exit(1);
            });
    },
    disconnect: () => {
        mongoose.connection
            .close()
            .then(() => {
                console.log("Disconnected from MongoDB");
            })
            .catch((err) => {
                console.log("Error disconnecting from MongoDB", err);
            });
    },
};
